package LeetCode.LeetCode2;

/**
 * 找出第一个不重复的字符
 * @author lumin
 * @date 2022/04/10 20:38
 **/
public class Num387 {
    public int firstUniqChar(String s) {
        char[] arr = s.toCharArray();
        if(arr.length == 1){
            return 0;
        }
        int i = 0;
        while(i < arr.length){
            int j = i + 1;
            while(j < arr.length){
                if(arr[i] == arr[j] && arr[i] != ' '){
                    arr[i] = arr[j] = ' ';
                    i++;
                    break;
                }else{
                    j++;
                }
            }
            return i;
        }
        return -1;
    }
}